import request from '@/utils/request'

// 查询待配单列表
export function listPendingMatching() {
  return request({
    url: '/fiscale/refund/pendingMatching',
    method: 'get'
  })
}

// 查询未匹配的报关单列表（用于配单异常页面）
export function listUnmatchedDeclarations(query) {
  return request({
    url: '/fiscale/refund/unmatchedDeclarations',
    method: 'get',
    params: query
  })
}

// 查询未匹配的发票列表（用于配单异常页面）
export function listUnmatchedInvoices(query) {
  return request({
    url: '/fiscale/refund/unmatchedInvoices',
    method: 'get',
    params: query
  })
}

// 查询已配单列表
export function listMatched(query) {
  return request({
    url: '/fiscale/refund/matched',
    method: 'get',
    params: query
  })
}

// 查询配单异常列表
export function listExceptions(query) {
  return request({
    url: '/fiscale/refund/exceptions',
    method: 'get',
    params: query
  })
}

// 取消配对
export function cancelMatching(matchingId) {
  return request({
    url: '/fiscale/refund/cancelMatching/' + matchingId,
    method: 'put'
  })
}

// 智能推荐
export function recommendMatching(declarationId) {
  return request({
    url: '/fiscale/refund/recommend',
    method: 'post',
    data: declarationId
  })
}

// 手动关联
export function manualMatching(data) {
  return request({
    url: '/fiscale/refund/manualMatching',
    method: 'post',
    data: data
  })
}

// 标记为异常
export function markException(data) {
  return request({
    url: '/fiscale/refund/markException',
    method: 'post',
    data: data
  })
}

// 查询待申报退税列表
export function listPendingDeclaration(query) {
  return request({
    url: '/fiscale/refund/pendingDeclaration',
    method: 'get',
    params: query
  })
}

// 生成退税数据
export function generateRefundData(matchingIds) {
  return request({
    url: '/fiscale/refund/generateRefundData',
    method: 'post',
    data: matchingIds
  })
}

// 正式申报
export function submitRefundDeclaration(batchId) {
  return request({
    url: '/fiscale/refund/submitRefundDeclaration/' + batchId,
    method: 'post'
  })
}

// 查询退税申报批次列表
export function listBatches(query) {
  return request({
    url: '/fiscale/refund/batches',
    method: 'get',
    params: query
  })
}

// 获取退税申报批次详情
export function getBatchDetail(batchId) {
  return request({
    url: '/fiscale/refund/batches/' + batchId,
    method: 'get'
  })
}

// 刷新申报状态
export function refreshStatus(batchId) {
  return request({
    url: '/fiscale/refund/refreshStatus/' + batchId,
    method: 'put'
  })
}

// 下载回执
export function downloadReceipt(batchId) {
  return request({
    url: '/fiscale/refund/downloadReceipt/' + batchId,
    method: 'get'
  })
}